/**  
* @Title: CompanyController.java
* @Package com.house.service.controller.company
* @version V1.0  
*/ 
package com.hjb.service.controller.company;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.hjb.service.annotation.LogInfo;
import com.hjb.service.annotation.LogType;
import com.hjb.service.company.ActivityService;
import com.hjb.service.domain.Activity;
import com.hjb.service.domain.RentOrder;

/**
* @ClassName: CompanyController
* @Description: TODO(团队风采)
* @author <a href="mailto:125671254@qq.com">Pan Xinwen</a>
* @date 2017年5月13日 下午5:16:58
*/
@RestController
@RequestMapping("/activity/v1")
public class ActivityController {

	@Autowired
	private ActivityService activityService;
	
	/**
	 * 
	* @Title: getCompanyMsg
	* @Description: TODO(获取公司基本信息)
	* @param @param request
	* @param @return    设定文件
	* @return Company    返回类型
	* @throws
	 */
	@LogInfo(logType=LogType.查询,operationContent="获取公司信息")
	@RequestMapping("getam")
	@ResponseBody
	public List<Activity> getActivityMsg(HttpServletRequest request){
		
		return activityService.getActivityMsg();
		
	}
	
	@LogInfo(logType=LogType.查询,operationContent="判断用户时候有参加老客户推荐新客户活动资格(如果有查询推荐的用户)")
	@RequestMapping("getRs")
	@ResponseBody
	public Map<String,Object> getRecommendStatus(HttpServletRequest request){
		String userId = request.getSession().getAttribute("userId")+"";
		//查询用户是否有参加活动的资格
		List<Map<String,Object>> list = activityService.getUserOrderForOneYearAndMore(userId);
//		List<Map<String,Object>> list = activityService.getUserOrderForOneYearAndMore("2017051322170858073337");
		
		Map<String,Object> result = new HashMap<String,Object>();
		
		if(list!=null && list.size() > 0) {
			result.put("code", 1);
			List<Map<String,Object>> all =  activityService.getAllRecommend(userId);
//			List<Map<String,Object>> all =  activityService.getAllRecommend("2017051322170858073337");
			result.put("all", all);
		}else{
			result.put("code", 0);
		}
		
		//查询所有有资格参加活动的用户的返利
		
		
		return result;
		
	}
	
}
